try { var dummy = SimpleTextChat; } catch ( e ) {

function SimpleTextChat(){
	// Do nothing. Use the init method instead.
	// The this.rtcf, property will be set after this constructor is called
	// but before the init method is called. You may need the this.rtcf
	// object. So, use init() to initialize your components.
}

// Required for AS 1 inheritance.
SimpleTextChat.prototype = new RTCFComponent();

SimpleTextChat.prototype.init = function(){
	// init component properties and its resources here...
	trace("SimpleTextChat.init>");
	
    // Allow any client, regardless of roles, to access this method:
    this.allowRemoteCall("deliverChatMessage");
    
    this.allowReadAccess("/");
    
    // Use the superclass method getSharedObject to get a shared object in the 
    // resource path for this component.
    this.chatMessages_so = this.getSharedObject("chatMessages");
    this.chatMessages_so.setProperty("init", "OK");
		
}

SimpleTextChat.prototype.deliverChatMessage = function(client, msg){
	trace("SimpleTextChat.deliverChatMessage> client: " + client + ", msg: " + msg);
	for (var i = 0; i < arguments.length; i++){
		trace("   arguments[" + i + "]: " + arguments[i] + " type: " + typeof arguments[i]);
	}
	
	var date = new Date();
	var dateString = date.getFullYear() + "," + (1 + date.getMonth()) + "," + (1 + date.getDay()) + " " +  date.toLocaleTimeString();
	
	msg = client.rtcf.user.displayName + " (id: " + client.id + ") at: " + dateString + " wrote:\n" + msg;
	
	this.chatMessages_so.send("receiveMessage", msg);
}


} // end catch
